package com.softserveinc.service;

import org.springframework.security.authentication.encoding.PasswordEncoder;
import org.springframework.security.authentication.encoding.ShaPasswordEncoder;

import java.util.UUID;

/**
 * Generates password based in user password and salt
 */


public class UserPasswordGenerator {

    public static void main(String[] args) {
        PasswordEncoder encoder = new ShaPasswordEncoder(256);

        String salt = UUID.randomUUID().toString();
        String pass = "user";
        String encodedPass = encoder.encodePassword(pass, salt);
        System.out.println("username = user");
        System.out.println("salt = \"" + salt + "\"");
        System.out.println("encodedPass = \"" + encodedPass + "\"");
        System.out.println("/******************************************/");

        String adminPass = "admin";
        String adminSalt = UUID.randomUUID().toString();
        String adminEncodedPass = encoder.encodePassword(adminPass, adminSalt);
        System.out.println("username = admin");
        System.out.println("salt = \"" + adminSalt + "\"");
        System.out.println("encodedPass = \"" + adminEncodedPass + "\"");
        System.out.println("/******************************************/");
    }
}
